	package com.msa.msaportal.webservice;
	
	import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.codec.binary.Base64;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
	
	public class App {

	@SuppressWarnings("resource")
	public static void main(String[] args) throws IOException {
		File file = new File("D:/cs_wj/paginationneiwang1.css");
		 InputStream in = new FileInputStream(file);	

		 //文件名
//		 String filename="20151.css";
		 // 取得文件大小
		 long length = file.length();
		
		 // 根据大小创建字节数组
		 byte[] bytes = new byte[(int) length];
		
		 // 读取文件内容到字节数组
		 int offset = 0;
		 int numRead = 0;
		 while (offset < bytes.length
		 && (numRead = in.read(bytes, offset, bytes.length - offset)) >= 0) {
		 offset += numRead;
		 }
		
		 // 读取完毕的校验
		 if (offset < bytes.length) {
		 throw new IOException("不能完全读取文件："+ file.getName());
		 }
		
		 in.close();
		
		 String encodedFileString = Base64.encodeBase64String(bytes);

		 System.out.println("{===文件===}"+encodedFileString);

		JaxWsDynamicClientFactory newInstance = JaxWsDynamicClientFactory.newInstance();
//		org.apache.cxf.endpoint.Client createClient = newInstance.createClient("http://localhost:8080/MSAPortal/ws/footerServices?wsdl");
//		org.apache.cxf.endpoint.Client createClient = newInstance.createClient("http://localhost:8080/MSAPortal/ws/headerServices?wsdl");
//		org.apache.cxf.endpoint.Client createClient = newInstance.createClient("http://localhost:8080/MSAPortal/ws/portletResourceServices?wsdl");
		org.apache.cxf.endpoint.Client createClient = newInstance.createClient("http://localhost:8080/MSAPortal/ws/TemplateOrStyle?wsdl");
//		org.apache.cxf.endpoint.Client createClient = newInstance.createClient("http://localhost:8080/MSAPortal/ws/portalResourceServices?wsdl");
		//===========测试路径=========
//		org.apache.cxf.endpoint.Client createClient = newInstance.createClient("http://localhost:8080/MSAPortal/ws/path?wsdl");
	try {
//		//===========测试路径=========
//		String data="{'path1':'dd','path2':'ddd'}";
//		Object[] objects = createClient.invoke("getPath", data);
//		System.out.println(objects[0].toString());

//	String data="{'footerName':'11','orgName':'11','orgId':'11','description':'11','public':'1','author':'11','authorId':'11','alter':'11','alterId':'11','createTime':'11','updateTime':'11','footContent':'11','FooterId':'11','templateOrStyleId':'543'}";
	//Object[] objects = createClient.invoke("testws", data);
//	Object[] objects = createClient.invoke("deleteFooter", "11");
//	System.out.println(objects[0].toString());
//	String data="{'footerName':'11','orgName':'11','orgId':'11','description':'11','public':'1','author':'11','authorId':'11','alter':'11','alterId':'11','createTime':'11','updateTime':'11','footContent':'11','FooterId':'11','templateOrStyleId':'543'}";
//	Object[] objects = createClient.invoke("addFooter", data);
//	Object[] objects = createClient.invoke("changeFooter", "552");
//	System.out.println(objects[0].toString());
		     
//	String data="{'headerName':'11','orgName':'11','orgId':'11','description':'11','public':'1','author':'11','authorId':'11','alter':'11','alterId':'11','createTime':'11','updateTime':'11','imageFile':'"+encodedFileString+"','imageName':'UUUUU.png','HeaderId':'11','templateOrStyleId':'136'}";
//	Object[] objects = createClient.invoke("addHeader", data);
//	String data="{'headerId':'435','imageFile':'"+encodedFileString+"','imageName':'wenjian_BB'}";
//	Object[] objects = createClient.invoke("changeHeader",data); 
//	System.out.println(objects[0].toString());

//	String data="{'headerName':'11','orgName':'11','orgId':'11','description':'11','public':'1','author':'11','authorId':'11','alter':'11','alterId':'11','createTime':'11','updateTime':'11','imageFile':'"+encodedFileString+"','imageName':'aaa.png','HeaderId':'11'}";
//	Object[] objects = createClient.invoke("addHeader", data);
////	Object[] objects = createClient.invoke("deleteHeader","11");
//	System.out.println(objects[0].toString());
	
//	String data="{'portletResourceName':'11','orgId':'11','description':'11','public':'1','author':'11','authorId':'11','alter':'11','alterId':'11','createTime':'11','updateTime':'11','portletResourceUrl':'11','portletResourceId':'11'}";
//	Object[] objects = createClient.invoke("addPortletResource", data);
//	Object[] objects = createClient.invoke("deletePortletResource","11");
//	System.out.println(objects[0].toString());
	
	String data="{'templateOrStyleName':'13','orgName':'13','orgId':'13','description':'13','public':'1','author':'13','authorId':'13','alter':'13','alterId':'13','createTime':'13','updateTime':'31','files':'"+encodedFileString+"','fileName':'jfali.css','fileType':'css','templateOrStyleId':'13'}";
	Object[] objects = createClient.invoke("addTemplateOrStyle", data);
//	String data="{'templateOrStyleId':'638','fileType':'css'}";
//	Object[] objects = createClient.invoke("delTemplateOrStyle",data);
	System.out.println(objects[0].toString());
		
//=========================================================================

	} catch (Exception e) {
	e.printStackTrace();
	}
		
	}

}
